package cn.nie.cn.nie.controller;


import cn.nie.entity.Document;
import cn.nie.service.SearchService;
import org.apache.solr.client.solrj.SolrServerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class SearchController {


    @Autowired
    private SearchService searchService;
    @RequestMapping("/search.do")
    public String search(String keyWords, Model model) throws SolrServerException {
        List<Document> documents =  searchService.searchResult(keyWords);

        model.addAttribute("documents",documents);

        return "detail";
    }

}
